/*
* Circle.cpp
*
*  Created on: Jan 20, 2011
*      Author: Helpful Learn Group
*/

#include "Circle.h"


namespace GSP280
{
	//Overloaded Constructor
	Circle::Circle ( double Radius )
	{
		radius = Radius;

		//set collision collisionBox
		collisionBox.setLocation(Location);
		collisionBox.setHeight((int)Radius);
		collisionBox.setWidth((int)Radius);
	}

	//set the radius of the circle
	void Circle::setRadius ( const double &Radius )
	{
		radius = Radius;

		//update collision collisionBox
		collisionBox.setHeight((int) Radius);
		collisionBox.setWidth((int) Radius);
	}

	//return the radius of the circle
	const double Circle::getRadius ( ) const
	{
		return radius;
	}

	//return collsionBox location
	const Vector2 Circle::getCollisionBox_Location() const
	{
		return ( collisionBox.getLocation() );
	}

	//return collsionBox location_X
	const float Circle::getCollisionBox_Location_X() const
	{
		return ( collisionBox.getLocation_X() );
	}

	//return collsionBox location_Y
	const float Circle::getCollisionBox_Location_Y() const
	{
		return ( collisionBox.getLocation_Y() );
	}

	//return collsionBox Height
	const int Circle::getCollisionBox_Height() const
	{
		return ( collisionBox.getHeight() );
	}

	//return collsionBox Width
	const int Circle::getCollisionBox_Width ( ) const
	{
		return ( collisionBox.getWidth() );
	}

	//calculate area of circle
	const double Circle::calcArea ( ) const
	{
		return (double(3.14159 * radius * radius));
	}

	//set the location of the circle given a vector
	void Circle::setLocation(const Vector2 &vect)
	{
		Location = vect;
		collisionBox.setLocation(vect); //update collision location
	}

	//set the location of the circle given x,y
	void Circle::setLocation(const float &x, const float &y)
	{
		Location.setVector2(x,y);
		collisionBox.setLocation(x,y); //update collision location
	}
	
	//set the location_X of the circle
	void Circle::setLocation_X(const float &x)
	{
		Location.setX(x);
		//update collision location_X
		collisionBox.setLocation_X(x);
	}
	
	//set the location_Y of the circle
	void Circle::setLocation_Y(const float &y)
	{
		Location.setY(y);
		collisionBox.setLocation_Y(y); //update collision location_Y
	}

	//get the location of the circle in Vector2
	const Vector2 Circle::getLocation() const
	{
		return Location; 
	}

	//get the location_X of the circle
	const float Circle::getLocation_X() const
	{
		return Location.getX();
	}

	//get the location_Y of the circle
	const float Circle::getLocation_Y() const
	{
		return Location.getY();
	}

	//Detect IF 'this'collides with input obj
	const bool Circle::intersects( const Circle &target )
	{
		bool hasCollided = false;

		if (
			(
			//(coll.getLocation_X() >= (this->getLocation_X() - coll.getCollisionBox_Width())) && (coll.getLocation_X() <= (this->getLocation_X() + this->getCollisionBox_Width()) )
			(this->getLocation_X() >= (target.getLocation_X() - this->getCollisionBox_Width())) && (this->getLocation_X() <= (target.getLocation_X() + this->getCollisionBox_Width()) )
			) &&
			(
			(this->getLocation_Y() >= (target.getLocation_Y() - this->getCollisionBox_Height())) && (this->getLocation_Y() <= (target.getLocation_Y() + target.getCollisionBox_Height()) )
			)
			)
		{
			hasCollided = true;
			cout << "Collision = true!\n\n";
		}
		else { hasCollided = false; cout << "Collision = false!\n\n"; }

		return ( hasCollided );
	}

}//namespace
